const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');


module.exports = {
  mode: "development",
  entry: {
    app: './src/main.ts',
    hot: "webpack/hot/dev-server.js",
    client: "webpack-dev-server/client/index.js?hot=true&live-reload=true"
  },
  devtool: "inline-source-map",
  module: {
    rules: [
      {
        test: /\.ts?$/,
        use: 'ts-loader',
        exclude: /node_modules/,
      },
      {
        test: /\.css?$/,
        use: [
          'style-loader',
          'css-loader'
        ],
      },
      {
        test: /\.(png|jpg|webp|jpeg|fbx|obj|mtl|glb)?$/,
        use: [
          'url-loader'
        ],
      }
    ],
  },
  resolve: {
    extensions: [
      '.tsx',
      '.ts',
      '.js',
      ".css",
      '.png',
      '.jpg',
      '.webp',
      '.jpeg',
      '.obj',
      '.fbx',
      '.mtl',
      '.glb',
    ],

    alias: {
      '@': path.resolve(__dirname, 'src')
    }
  },
  output: {
    filename: 'src/[name].js',
    path: path.resolve(__dirname, 'dist'),
    clean: true,
  },
  devServer: {
    static: './dist',
    hot: false,
    client: false,
  },
  plugins: [
    new HtmlWebpackPlugin({
      title: "我是一个title",
    }),
    new webpack.HotModuleReplacementPlugin(),
  ],
  optimization: {
    runtimeChunk: 'single'
  },
  stats: "minimal",

};
